package com.czk.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/5/24 16:38
 */
@RestController
public class SpringSessionController {
    @GetMapping("/session")
    public String session(HttpSession session) {
        session.setAttribute("npy", "nzq");
        return "存储成功";
    }

    @GetMapping("/sessionGet")
    public String get(HttpSession session) {
        // 拿到值
        String name = (String) session.getAttribute("name");
        return name;
    }
}
